package com.taru.university.service.impl;

import com.taru.university.mapper.AnaliseMapper;
import com.taru.university.mapper.DataMapper;

import com.taru.university.model.Datas;
import com.taru.university.service.DataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DataServiceImpl implements DataService {

    @Autowired
    DataMapper dataMapper;


    @Override
    public List<Datas> queryDataByBatchNumber(String dateBatchNumber) {
        return dataMapper.queryDataByBatchNumber(dateBatchNumber);
    }

    @Override
    public double insertData(Datas data) {
        dataMapper.insertData(data);

        double number = 0;
            int wd = Integer.parseInt(data.getDatesTemperature());
            int sd = Integer.parseInt(data.getDatesHumidity());
        if(data.getDatesSort().equals("枣瘿蚊")){
            number = wd*3.972-0.002*sd-38.819;
            System.out.println(number);
        }else if(data.getDatesSort().equals("枣树叶螨")){
            number = wd*1.534-0.051*sd-19.308;
            System.out.println(number);
        }else if(data.getDatesSort().equals("截形叶螨")){
            number = wd*6.508-0.798*sd-168.358;
            System.out.println(number);
        }

        System.out.println("123");


        return number;
    }

    @Override
    public void deleteData(String dateBatchNumber) {
        dataMapper.deleteData(dateBatchNumber);
    }
}
